/*
** malloc.h for malloc in /home/newin/malloc
**
** Made by
** Login  <@epitech.eu>
**
** Started on  Wed Jan 30 22:01:10 2013
** Last update Wed Feb 06 17:26:20 2013 vincent leroy
*/

#ifndef MALLOC_H_
# define MALLOC_H_

#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include "malloc.conf.h"

#define ADD(pt, x)	(void*)((unsigned long)(pt) + (x))
#define SUB(pt, x)	(void*)((unsigned long)(pt) - (x))

#define put(s)		write(1, s, strlen(s))

typedef struct header
{
    int size;
    struct header* next;
    struct header* back;
} header_t;

void *malloc(size_t );
void free(void *);
void *realloc(void *, size_t);
void *calloc(size_t, size_t);

void show_alloc_mem();

void my_putaddr(void *pt);
int my_putnbr(int n);

header_t* __getFirstAllocated();
void __setFirstAllocated(header_t* new);
void* __getSbrk0();
void __setSbrk0(void *s);
void* __searchFree(size_t length);

#ifdef __MYMALLOC_THREAD_SAFE_OPTS_
#define LOCK pthread_mutex_lock(&__mutex1)
#define UNLOCK pthread_mutex_unlock(&__mutex1)
#else
#define LOCK
#define UNLOCK
#endif

#endif /* !MALLOC_H_ */
